home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1993 / MacHack 1993.toast / MacHack™ 1987-1992 / MacHack™ '90 / Other Stuff / Demos ƒ / TOPS SoftTalk Package / SoftTalk.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-06  |  11.8 KB  |  405 lines  |  [TEXT/KAHL]

  1. /*
  2. ------------------------------------------------------------------------------
  3. |    Sun Microsystems, TOPS Division
  4. |    950 Marina Village Parkway
  5. |    P.O. Box 4016
  6. |    Alameda, CA 94501
  7. |    
  8. |    Copyright (c) 1989 Sun Microsystems, Inc. All rights reserved.
  9. |    
  10. |    Sun considers its source code as an unpublished, proprietary trade secret,
  11. |    and it is available only under strict license provisions. This copyright
  12. |    notice is placed here only to protect Sun in the event the source is deemed
  13. |    a published work. Disassembly, decompilation, or other means of reducing the
  14. |    object code to human readable form is prohibited by the license agreement
  15. |    under which this code is provided to the user or company in possession of
  16. |    this copy.
  17. |    
  18. |    RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the Government
  19. |    is subject to restrictions as set forth in subparagraph (c) (1) (ii) of the
  20. |    Rights in Technical Data and Computer Software clause at DFARS 52.227-7013
  21. |    and in similar clauses in the FAR and NASA FAR supplement.
  22. ------------------------------------------------------------------------------
  23. */
  24.  
  25.  
  26. /*
  27. ================================================================================
  28. **
  29. **    Project:    SoftTalk
  30. **
  31. **    File:        SoftTalk.h
  32. **
  33. **    Purpose
  34. **        This file presents the interface to the SoftTalk module
  35. **
  36. **    Usage:
  37. **        include this file into any module that will use SoftTalk.
  38. **
  39. **    ----------------------------------------------------------------------------
  40. **
  41. **    Version        Date        Author        Description
  42. **    -------        ----        ------        -----------
  43. **    1.0.2        30-Aug-89     MAC            Second draft.
  44. **    1.0.1        17-Aug-89     MAC            First draft.
  45. **
  46. ================================================================================
  47. */
  48.  
  49.  
  50. #ifndef    __SoftTalk__
  51. #define __SoftTalk__
  52.  
  53.  
  54. /*
  55. **    ----------------------------------------------------------------------------
  56. **        INCLUDES
  57. **    ----------------------------------------------------------------------------
  58. */
  59. #include "StdHdr.h"
  60.  
  61.  
  62. /*
  63. **    ----------------------------------------------------------------------------
  64. **        CONST
  65. **    ----------------------------------------------------------------------------
  66. */
  67. #define    kDefaultRequests    (0)
  68.     /* use for STOpenServer, STOpenSession if you want the default number of buffers */
  69.  
  70. #define    kStillLooking    (-1)
  71.     /* returned by STList if it started an async lookup */
  72.  
  73.     /* predefined service routine ranks */
  74. #define    kInterruptRank    (0)
  75. #define    kSystemTaskRank    (1)
  76.  
  77.     /* codes for the mandatory service routines that must be registered by every server */
  78. #define    kAcceptSessionCode    (0x0004)
  79. #define    kFreeSessionCode    (0x0006)
  80.  
  81.     /* errors */
  82. #define kEInitFailed (-1)
  83. #define kESuccess (0)
  84. #define    kCloseConnectionMsg    (0)
  85.  
  86.  
  87.  
  88. /*
  89. **    ----------------------------------------------------------------------------
  90. **        TYPE
  91. **    ----------------------------------------------------------------------------
  92. */
  93. typedef INT32 STResult;
  94.     /* the return value from a SoftTalk function */
  95.  
  96. typedef void* STServer;
  97.     /* the "magic cookie" for a SoftTalk server */
  98.  
  99. typedef void* STSession;
  100.     /* the "magic cookie" for a SoftTalk session */
  101.  
  102. typedef INT32 STArg;
  103.     /* the universal type for all SoftTalk function arguments */
  104.  
  105. typedef    INT32    (*Func32Ptr)();
  106.     /* ptr to a function that returns an INT32 */
  107.  
  108. typedef    void    (*FuncVoidPtr)();
  109.     /* ptr to a function that returns void */
  110.  
  111.  
  112. typedef    UINT32    AddrBlock;
  113.     /*
  114.     **    This is a flaw in the SoftTalk armour against AppleTalk.
  115.     **    In order to find the owner of a duplicate name, we have
  116.     **    to know the structure of an AppleTalk network address,
  117.     **    and some of the private part of the list item structure.
  118.     */
  119.  
  120. typedef    struct STServerSpec {
  121.     struct STServerSpec*    link;
  122.     BYTE*                name;
  123.     INT16                len;
  124.     BYTE*                stat;
  125.     AddrBlock*            net;
  126. } STServerSpec, *STServerSpecPtr;
  127.     /* List elements returned by the STList command */
  128.  
  129.  
  130.  
  131.  
  132. /*
  133. **    ============================================================================
  134. **        PROTOTYPES
  135. **    ============================================================================
  136. */
  137.  
  138.  
  139. /*
  140. **    ============================================================================
  141. **        Common Entry Points
  142. **    ============================================================================
  143. */
  144.  
  145. STResult STInitialize(void);
  146.     /* 
  147.     |    Purpose:    initialize the SoftTalk library
  148.     |
  149.     |    Usage: Call from a client module to intialize the SoftTalk library.
  150.     */
  151.  
  152.  
  153. STResult STGetVersion(void);
  154.     /* 
  155.     |    Purpose: Obtain the version number of SoftTalk.
  156.     */
  157.  
  158. void STGetSizes(UINT32* pCommandMax, UINT32* pWriteMax, UINT32* pReadMax, UINT32* pStatusMax);
  159.     /*
  160.     |    Purpose: Determine implementation dependent maximums:
  161.     |
  162.     |    Usage:
  163.     */
  164.  
  165.  
  166.  
  167. /*
  168. **    ============================================================================
  169. **        Server Entry Points
  170. **    ============================================================================
  171. */
  172.  
  173. STResult STOpenServer(STServer* pServerID, UINT32 nRequests);
  174.     /*
  175.     |    Purpose:
  176.     |        Open a SoftTalk server, specifying the desired number of concurrent 
  177.     |        requests .  Allocate and return a server-id (STServer) and return the actual
  178.     |        number of concurrent client requests that can be serviced.
  179.     |
  180.     |    Usage:
  181.     |        Called externally after STInitialize(). Pass in a pointer to the STServer
  182.     |        ident, as well as the number of concurrent requests desired.
  183.     */
  184.  
  185.  
  186.  
  187. STResult STCloseServer(STServer serverID);
  188.     /*
  189.     |    Purpose: Close a SoftTalk server.
  190.     |
  191.     |    Usage:
  192.     |        Call with a server-id returned by STOpenServer().  Returns kESuccess, or a 
  193.     |        negative error code.
  194.     */
  195.  
  196.  
  197.  
  198. STResult STAlias(STServer serverID, BYTE* name);
  199.     /*
  200.     |    Purpose:    give the server a name
  201.     |        Give the server specified by "serverID" a human-readable name.  This name is
  202.     |        typically of the form "name:type@zone" (standard AppleTalk).
  203.     |
  204.     |    Usage:
  205.     |        Call with a server-id returned by STOpenServer().  Returns kESuccess, or a 
  206.     |        negative error code.
  207.     */
  208.  
  209.  
  210.  
  211. STResult STUnalias(STServer serverID, BYTE* name);
  212.     /*
  213.     |    Purpose:    remove an alias for the server
  214.     |        Remove a previous alias for the server.
  215.     |
  216.     |    Usage:
  217.     |        Call with a server-id returned by STOpenServer().  Returns kESuccess, or a 
  218.     |        negative error code.
  219.     */
  220.  
  221.  
  222.  
  223. STResult STSetStatus(STServer serverID, BYTE* block, UINT32 blockSize);
  224.     /*
  225.     |    Purpose:    set the server's status bytes
  226.     |        Set the "status" block that is associated with the server.  This block
  227.     |        is not interpreted by SoftTalk and can be used to help a client get info
  228.     |        about the server in a client specific way (i.e. icon info, etc.).
  229.     |
  230.     |    Usage:
  231.     |        Call with a server-id returned by STOpenServer(), a pointer to the block
  232.     |        and the length of the block of data.  The maximum size block that SoftTalk can
  233.     |        handle is implementation dependant and can be determined by calling GetSizes()
  234.     |        (see below).  Returns kESuccess, or a negative error code.
  235.     */
  236.  
  237.  
  238.  
  239. STResult STRegister(STServer serverID, UINT32 code, Func32Ptr F, UINT32 rank, BYTE* format);
  240.     /*
  241.     |    Purpose:    register a service routine
  242.     |        Register a service routine for the server specified by "serverID".
  243.     |
  244.     |    Usage:
  245.     |        Call with a server-id returned by STOpenServer(), the two letter code that
  246.     |        designates the routine (as in 'F1'), the ptr to the service routine, the
  247.     |        rank of the routine, and a string that describes the format of the arguments.
  248.     |        The rank is used for scheduling purposes (exactly how???).  The service routine
  249.     |        may be called at interrupt times so special steps need to be taken if it accesses
  250.     |        globals.  Also, currently the service routine is called with arguments in
  251.     |        registers d0-d7, so assembly glue is needed to convert this into a C function call.
  252.     |        Returns kESuccess, or a negative error code.
  253.     */
  254.  
  255.  
  256.  
  257. STResult STReply(BYTE* buffer, UINT32 count, INT32 result);
  258.     /*
  259.     |    Purpose:    return data to client
  260.     |        Return data into a client's buffer within a service routine.
  261.     |
  262.     |    Usage:
  263.     |        If one of the arguments to a service routine is a ptr/len pair this call
  264.     |        is used to return the data into the client's buffer.
  265.     |        Return values???
  266.     */
  267.  
  268.  
  269.  
  270. STResult STHear(STServer serverID, UINT32 rank);
  271.     /*
  272.     |    Purpose:    accept a service request
  273.     |        Tell SoftTalk that you are willing to accept a service request.  How does
  274.     |        SoftTalk's scheduling mechanism work???
  275.     |
  276.     |    Usage:
  277.     |        Call with a server-id returned by STOpenServer(), and the rank of the routine
  278.     |        you are willing to service.  If a routine was serviced, then STHear returns
  279.     |        non-zero; if a routine was _not_ serviced then STHear() returns zero.
  280.     */
  281.  
  282.  
  283.  
  284. STResult STSignal(STServer serverID, STSession sessionID, INT32 message);
  285.     /*
  286.     |    Purpose:
  287.     |        Allow the server to communicate a message to the client.  Can be used for
  288.     |        exceptions, panic, shutdown, etc.
  289.     |
  290.     |    Usage:
  291.     |        Call with a server-id returned by STOpenServer(), the session-ID for
  292.     |        a particular client (obtained from the client) and a message.  If teh message
  293.     |        is equal to kCloseConnectionMsg, the connection is terminated.  Otherwise,
  294.     |        the message is passed on to the client.
  295.     |        Returns kESuccess, or a negative error code.
  296.     */
  297.  
  298.  
  299.  
  300.  
  301.  
  302. /*
  303. **    ============================================================================
  304. **        Client Entry Points
  305. **    ============================================================================
  306. */
  307.  
  308. STResult STList(STServerSpecPtr* listElts, BYTE* spec);
  309.     /*
  310.     |    Purpose:
  311.     |        Locate all servers that match a name specification.
  312.     |
  313.     |    Usage:
  314.     |        Pass in an NBP search specification (i.e. "=:AFPServer:*"), and the address
  315.     |        of the head of the linked-lists of the found servers.  STList() returns
  316.     |        the number of servers found, or a negative error code.  If STList() returns the
  317.     |        the special value kStillLooking, and async lookup has been triggered, and subsequent
  318.     |        calls to STList() with the same search-spec will return the number of servers
  319.     |        found since the last call.
  320.     */
  321.  
  322.  
  323.  
  324. STResult STUnlist(BYTE* spec);
  325.     /*
  326.     |    Purpose:
  327.     |        Deallocate the list of ServerSpecs that matches the given NBP search-spec.
  328.     |
  329.     |    Usage:
  330.     |        Call with the same NBP spec used for the STList() call.
  331.     |        Returns kESuccess, or a negative error code.
  332.     */
  333.  
  334.  
  335.  
  336. STResult STOpenSession(STSession* pSessionID, BYTE* spec, Func32Ptr Notify, UINT32 nRequests);
  337.     /*
  338.     |    Purpose:
  339.     |        Open a session with the server specified in the NBP spec.
  340.     |
  341.     |    Usage:
  342.     |        Call with the NBP spec for the desired server, a ptr to a special 
  343.     |        interrupt-level service routine Notify(), the number of buffers needed for
  344.     |        multiple async requests.  The routine will allocate a sessionID.
  345.     |        Returns the actual number of buffers allocated, or a negative error code.
  346.     */
  347.  
  348.  
  349.  
  350. STResult STCloseSession(STSession sessionID);
  351.     /*
  352.     |    Purpose:
  353.     |        Close the session identified by sessionID.
  354.     |
  355.     |    Usage:
  356.     |        Call with a ssession-id returned by STOpenSession().
  357.     |        Returns kESuccess, or a negative error code.
  358.     */
  359.  
  360.  
  361.  
  362. STResult STAsk(STSession sessionID, INT32* pResult, UINT32 code, BYTE* format,...);
  363.     /*
  364.     |    Purpose:
  365.     |        Execute the specified service routine on the server with the given arguments.
  366.     |
  367.     |    Usage:
  368.     |        Call with a session-id returned by STOpenSession(), a ptr to the return value,
  369.     |        the code for the routine to be invoked (i.e. 'F1'), the format string describing
  370.     |        the arguments, and then the arguments themselves.
  371.     |        Returns kESuccess, or a negative error code.
  372.     */
  373.  
  374.  
  375.  
  376. STResult STAsync(STSession sessionID, FuncVoidPtr Done, UINT32 arg, UINT32 code, BYTE* format, ...);
  377.     /*
  378.     |    Purpose:
  379.     |        Trigger the execution of the specified service routine on the server
  380.     |        with the given arguments.
  381.     |
  382.     |    Usage:
  383.     |        Call with a session-id returned by STOpenSession(), a ptr to a interrupt-level
  384.     |        completion routine Done(INT32 error, INT32 result, INT32 arg), 
  385.     |        the code for the routine to be invoked (i.e. 'F1'), the format string describing
  386.     |        the arguments, and then the arguments themselves.  The value arg is not interpreted
  387.     |        by SoftTalk; it is for the convenience of the client and will be passed into
  388.     |        the completion routine.  This could be used, for example, to pass the address
  389.     |        of a variable to the completion routine.
  390.     |        Returns kESuccess, or a negative error code.
  391.     */
  392.  
  393.  
  394.  
  395. void STPoll(void);
  396.     /*
  397.     |    Purpose: This does nothing on the Macintosh.
  398.     */
  399.  
  400.  
  401.  
  402.  
  403.  
  404. #endif
  405.